<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<% 
	String path = request.getContextPath(); //解決跳轉后樣式丟失的問題
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 	
%>
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="<%=path%>/background/style/resource/Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="<%=path%>/background/style/resource/Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="<%=path%>/background/style/resource/Css/style.css" />
    <script type="text/javascript" src="<%=path%>/background/style/resource/Js/jquery.js"></script>
    <script type="text/javascript" src="<%=path%>/background/style/resource/Js/jquery.sorted.js"></script>
    <script type="text/javascript" src="<%=path%>/background/style/resource/Js/bootstrap.js"></script>
    <script type="text/javascript" src="<%=path%>/background/style/resource/Js/ckform.js"></script>
    <script type="text/javascript" src="<%=path%>/background/style/resource/Js/common.js"></script>

    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
    
    <script>
function Validate(){
    return validateprice()&&validatecount();
}

function validateprice(){
    var msg = $("#pmsg");
       msg.html("");
     var obj = $("#price").val();
     var reg = new RegExp("^[0-9]*$");
        if(!reg.test(obj)){
            msg.html("请输入数字");
            return false;
        }
        reg = new RegExp("^[0-9]*[1-9][0-9]*$");
         if(!reg.test(obj)){
                msg.html("请输入正整数");
                  return false;
        }
     
    return true;
}

function validatecount(){
    var msg = $("#cmsg");
     msg.html("");
     var obj = $("#count").val();
     var reg = new RegExp("^[0-9]*$");
     if(!reg.test(obj)){
        msg.html("请输入数字");
          return false;
      }
     reg = new RegExp("^[0-9]*[1-9][0-9]*$");
     if(!reg.test(obj)){
            msg.html("请输入正整数");
              return false;
    }
    
    return true;
}
</script>
</head>
<body>
<form action="/tbpoject/business2/updategoodsbyid?id=${info.id}&sid=${info.sid}&sortid=${info.sortid}&time=${info.time}" method="post" class="definewidth m20">
<table class="table table-bordered table-hover definewidth m10">
	
	 <tr>
        <td width="10%" class="tableleft">商品ID</td>
        <td><span id="id">${info.id}</span></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">商品名</td>
        <td><input type="text" name ="name" value="${info.name }"/></td>
    </tr>
   
    <tr>
        <td class="tableleft">价格</td>
        <td><input type="text" id="price" name="price" value="${info.price }" onblur="validateprice()"/><span id="pmsg"></span></td>
    </tr>
    <tr>
        <td class="tableleft">数量</td>
        <td><input type="text" id="count" name="count" value="${info.count }" onblur="validatecount()"/><span id="cmsg"></span></td>
    </tr>
    <tr>
        <td class="tableleft"></td>
        <td>
            <button type="submit" class="btn btn-primary"  onclick="return Validate()" >保存</button> &nbsp;&nbsp;<button type="reset" class="btn btn-success" name="backid" id="backid">重置</button>
        </td>
    </tr>
</table>
</form>
</body>
</html>


